<template>
	<view id="pay_success">
		<view class="main">
			<image class="pay_success" src="@/static/sy/mine-detailsmine-details/pay_success.png" mode=""></image>
			<view class="title">支付成功</view>
			<view class="price">
				<text style="font-size: 34rpx;">¥</text>
				<text>{{data.payMoney}}</text>
			</view>
			<view class="line"></view>
			<view class="detail">
				<view class="detail_l">订单编号</view>
				<view class="detail_r">
					<text>{{data.thirdPartyNo}}</text>
					<text class="copy_txt" @click="copy(data.thirdPartyNo)">复制</text>
				</view>
			</view>
			<view class="detail">
				<view class="detail_l">交易时间</view>
				<view class="detail_r">
					<text>{{data.transactionTime}}</text>
				</view>
			</view>
			<image v-if="type=='1'" class="button_box" src="@/static/sy/mine-detailsmine-details/ljsy.png" mode="" @click="useNow"></image>
		</view>
	</view>
</template>

<script>
	import {
		payReslut
	} from '@/api/sy.js'
	export default {
		data() {
			return {
				num: 0, 
				data:{},
				type:'1',//1:平台  2：第三方
				lat:'',
				lnt:'',
			}
		},
		onLoad(e){
			this.type = e.type
			this.lat = e.lat
			this.lnt = e.lnt
		    this.getPayResult(e.orderId)
		},
		methods: {
			async getPayResult(orderId){
				// console.log(id)
				var _this = this
				uni.showLoading({
					title:'加载中'
				})
				try{
					var res = await payReslut(orderId)
					if(res.result != ''){
						  this.data = res.result
						  uni.hideLoading()
					}else{
						if(this.num < 100){
							setTimeout(res=>{
								 _this.num++
								 _this.getPayResult(orderId)
							},1000)
						}else{
							uni.hideLoading()
						}
					}
				}catch{
					uni.hideLoading()
				}
			},
			copy(text) { //复制
				if(text != ''){
					var _this = this
					 _this.$copyText(text).then(
			            res => {
			              uni.showToast({
			                title: '复制成功',
			                icon: 'none'
			              })
			            }
			          )
				}
			},
			useNow(){ //立即使用
			    let info = {
					lat: this.lat,
					lnt: this.lnt
				}
			    let latLntdata = JSON.stringify(info)
				window.location.href =  "/pages/pay/mine-details-one?latLntdata=" + latLntdata + '&id=' + this.data.couponId + '&type=' + '1'
			},
		}
	}
</script>

<style>
	.main{
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 80rpx;
	}
	.pay_success{
		width: 220rpx;
		height: 220rpx;
		margin-bottom: 42rpx;
	}
	.title{
		font-size: 30rpx;
		color: #000000;
		margin-bottom: 14rpx;
	}
	.price{
		font-size: 48rpx;
		color: #FF361B;
	}
	.line{
		width: 670rpx;
		height: 2rpx;
		background-color: #D8D8D8;
		margin: 36rpx 0 80rpx;
	}
	.detail{
		display: flex;
		justify-content: space-between;
		width: 670rpx;
		margin-bottom: 18rpx;
	}
	.detail_l{
		font-size: 28rpx;
		color: #999999CC;
		margin-right: 10rpx;
	}
	.detail_r{
		font-size: 28rpx;
		color: #000000;
		width: 536rpx;
		word-wrap: break-word;
		text-align: right;
	}
	.copy_txt{
		font-size: 28rpx;
		color: #1774FF;
		margin-left: 16rpx;
	}
	.button_box{
		width: 322rpx;
		height: 84rpx;
		margin-top: 134rpx;
	}
</style>
